import { defineStore } from 'pinia'
import * as THREE from 'three'

type Weather = 'sunny' | 'rainy' | 'snowy'

interface SceneState {
  cameraPosition: THREE.Vector3
  cameraTarget: THREE.Vector3
  isNightMode: boolean
  currentWeather: Weather
  isBloomEnabled: boolean
  isShadowsEnabled: boolean
}

export const useSceneStore = defineStore('scene', {
  state: () => ({
    cameraPosition: new THREE.Vector3(0, 5, 10),
    cameraTarget: new THREE.Vector3(0, 0, 0),
    isNightMode: false,
    currentWeather: 'sunny' as Weather,
    isBloomEnabled: true,
    isShadowsEnabled: true
  }),

  actions: {
    setCameraPosition(position: THREE.Vector3) {
      this.cameraPosition = position
    },

    setCameraTarget(target: THREE.Vector3) {
      this.cameraTarget = target
    },

    toggleNightMode() {
      this.isNightMode = !this.isNightMode
    },

    setWeather(weather: Weather) {
      this.currentWeather = weather
    },

    toggleBloom() {
      this.isBloomEnabled = !this.isBloomEnabled
    },

    toggleShadows() {
      this.isShadowsEnabled = !this.isShadowsEnabled
    }
  },

  persist: true
})
